home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Trial / Paint Shop Pro XI / Data1.cab / _893D54EDA52F467E947F784ECFEA7371 < prev    next >
Encoding:
Text File  |  2006-08-04  |  2.1 KB  |  58 lines

  1. from PSPApp import *
  2.  
  3. def ScriptProperties():
  4.     return {
  5.         'Author': u'Corel Corporation',
  6.         'Copyright': u'Copyright (c) 2002-2006 Corel Corporation. All rights reserved.',
  7.         'Description': "Open a file duplicate it and then close the original",
  8.         'Host': u'Paint Shop Pro 9',
  9.         'Host Version': u'9.00'
  10.         }
  11.  
  12. def Do(Environment):
  13.     # Save off a list of the documents currently open
  14.     OpenDocsBefore = App.Documents
  15.     
  16.     App.Do( Environment, 'FileOpen', {
  17.             'ShowPreview': False, 
  18.             'EnableBrowser': True, 
  19.             'FavFileList': [], 
  20.             'GeneralSettings': {
  21.                 'ExecutionMode': App.Constants.ExecutionMode.Interactive, 
  22.                 'AutoActionMode': App.Constants.AutoActionMode.Match,
  23.                 'Version': ((9,0,0),1)
  24.                 }
  25.             })
  26.  
  27.     # Get the list of documents open after the call to FileOpen (could be zero, could be one, could be many)
  28.     OpenDocsAfter= App.Documents
  29.  
  30.     # Loop through the currently open documents, and if a document wasn't open before, duplicate it, and close the original.
  31.     for doc in OpenDocsAfter:
  32.         if not DocWasAlreadyOpen(OpenDocsBefore, doc):
  33.             App.Do( Environment, 'DuplicateWindow', {
  34.                     'GeneralSettings': {
  35.                         'ExecutionMode': App.Constants.ExecutionMode.Default, 
  36.                         'AutoActionMode': App.Constants.AutoActionMode.Match,
  37.                         'Version': ((9,0,0),1)
  38.                         }
  39.                     },
  40.                     doc)
  41.  
  42.             App.Do( Environment, 'FileClose', {
  43.                     'GeneralSettings': {
  44.                         'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  45.                         'AutoActionMode': App.Constants.AutoActionMode.Match,
  46.                         'Version': ((9,0,0),1)
  47.                         }
  48.                     },
  49.                     doc)
  50.  
  51.  
  52. def DocWasAlreadyOpen(OldOpenDocs, doc):
  53.     for olddoc in OldOpenDocs:
  54.         if (doc.Name == olddoc.Name) and (doc.Title == olddoc.Title):
  55.             return 1
  56.  
  57.     return 0
  58.